unit uScript;

interface

uses Classes;

type
  TScript = class(TObject)
  private
    SL: TStringList;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Clear;
    function Key(X, Y: Word): string;
    function Name(I: Integer): string;
    function Value(S: string): string;
    procedure Run(X, Y: Word);
    procedure LoadFromFile(FileName: string);
    procedure SaveToFile(FileName: string);
  end;

implementation

uses SysUtils, uBox;

const
  LS = '%s=%s';
  EX = '.scr';
  
{ TScript }

procedure TScript.Clear;
begin
  SL.Clear
end;

constructor TScript.Create;
begin
  SL := TStringList.Create
end;

destructor TScript.Destroy;
begin
  SL.Free;
  inherited
end;

function TScript.Key(X, Y: Word): string;
begin
  Result := Format('%dx%d', [X, Y]);
end;

procedure TScript.LoadFromFile(FileName: string);
begin
  FileName := ChangeFileExt(FileName, EX);
  if FileExists(FileName) then SL.LoadFromFile(FileName);
end;

procedure TScript.SaveToFile(FileName: string);
begin
  FileName := ChangeFileExt(FileName, EX);
  SL.SaveToFile(FileName);
end;

function TScript.Name(I: Integer): string;
begin
  Result := SL.Names[I];
end;

function TScript.Value(S: string): string;
begin
  Result := SL.Values[S];
end;

procedure TScript.Run(X, Y: Word);
begin
  Box('SCRIPT');
end;

end.
